package com.xgkj.diyiketang.task;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.xgkj.diyiketang.data.EatShowUserInfo;
import com.xgkj.diyiketang.http.CouponHttpRequest;
import com.xgkj.diyiketang.http.CouponHttpResponse;
import com.xgkj.diyiketang.http.engine.CouponHttpBaseTask;
import com.xgkj.diyiketang.http.engine.TaskResultCode;
import com.xgkj.diyiketang.util.LogUtils;


/**
 * Created by windo on 2015/11/24.
 */
public class GetUserDetailTask extends CouponHttpBaseTask {

    public GetUserDetailTask() {
        super();
    }

    @Override
    protected void processResponseData(CouponHttpResponse response) {
        JSONObject json = response.getBody();
        EatShowUserInfo userInfo = null;
        if (json != null) {
            userInfo = JSON.parseObject(json.toString(), EatShowUserInfo.class);
        }
        notifyTaskCompleted(TaskResultCode.SUCCESS, userInfo);
    }

    @Override
    protected void prepareRequest() {
        super.prepareRequest();
        if (mPhase == TASK_PHASE_INIT) {
            CouponHttpRequest loginRequset = new CouponHttpRequest();
            JSONObject jsonData = new JSONObject();
            loginRequset.setData(jsonData.toString());
            loginRequset.setApiNo(ApiNo.GETUSERDETAIL);
            addRequest(loginRequset);
        }
    }
}
